Component({
  data: {
    active: 0,
    list: [{
        "pagePath": "/pages1/index1/index1",
        "text": "产 品",
        "iconPath": "/img/lb0.png",
        "selectedIconPath": "/img/lb1.png"
      },
      {
        "pagePath": "/pages/wode/wode",
        "text": "我 的",
        "iconPath": "/img/hy1.png",
        "selectedIconPath": "/img/hy0.png"
      }
    ]
  },
  methods: {
    onChange(event) {
      this.setData({
        active: event.detail
      });
      wx.switchTab({
        url: this.data.list[event.detail].pagePath
      });
    },
    pushTab() {
      this.data.list.unshift({
        "pagePath": "/pages/index/index",
        "text": "首 页",
        "iconPath": "/img/sy0.png",
        "selectedIconPath": "/img/sy1.png"
      })
      console.log(this.data.list);
      this.setData({
        list: this.data.list
      })
    },
    init() {
      const page = getCurrentPages().pop();
      this.setData({
        active: this.data.list.findIndex(item => item.pagePath === `/${page.route}`)
      });
    }
  }
});